from django.contrib.auth.mixins import LoginRequiredMixin
from django import http

# 继承LoginRequiredMixin类，重写handle_no_permission()方法
class LoginRequiredJSONMixin(LoginRequiredMixin):
	# 若用户未登录，直接返回json给前端
    def handle_no_permission(self):
        return http.JsonResponse({'code': 4001, 'errmsg': '用户未登录'})
